﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WinnerCMS.Data
{
    public interface IRepository<T> where T : class,new()
    {
        T Create();

        T Update(T entity);

        T Insert(T entity);

        void Delete(object id);

        void Delete(T entity);

        T Find(params object[] keyValues);

        IList<T> FindAll();

        IList<T> FindAll(Func<T, object> orderKey, int pageSize, int pageIndex);

        IList<T> FindAll(Func<T, bool> predicate);

        IList<T> FindAll(Func<T, bool> predicate, Func<T, object> orderKey, int pageSize, int pageIndex);

        IList<T> FindBySql(string sql, params object[] parameters);

        int Sum(Func<T, int> selector);

        int Count(Func<T, bool> predicate);

        TResult Max<TResult>(Func<T, TResult> selector);

        TResult Min<TResult>(Func<T, TResult> selector);
    }
}